package com.dotflat.milestone.controller;

import com.dotflat.milestone.po.CheckSheet;
import com.dotflat.milestone.po.CheckSheetDimension;
import com.dotflat.milestone.po.CheckSheetTarget;
import com.dotflat.milestone.service.CheckSheetExportService;
import com.matt.commons.model.StatusResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.UUID;

import static com.matt.foundation.constant.RequestConstant.TICKET;


@RestController
@RequestMapping("/v2/checksheet")
@Slf4j
@Api(tags = "里程碑 - 发展检表")
public class CheckSheetExportController{

    @Autowired
    CheckSheetExportService checkSheetExportService;


    @ApiOperation(value = "获取列表")
    @GetMapping("/export")
    public StatusResponse getList(@RequestHeader(TICKET) String ticket){

        CheckSheet sheet = new CheckSheet();
        sheet.setUuid(UUID.randomUUID().toString());  //可以用其他逻辑代替，只是用来区分临时文件的文件名
        sheet.setChildName("罗逸修");
        sheet.setChildMonth("39");
        sheet.setSheetMonth("36-40m");
        sheet.setDimensionList(Arrays.asList(new CheckSheetDimension[] {
                new CheckSheetDimension("粗大动作", Arrays.asList(new CheckSheetTarget[]{
                        new CheckSheetTarget("△","1俯卧头部翘动", "宝宝呈俯卧姿势时，能尝试抬头。"),
                        new CheckSheetTarget("△111","1抬肩坐起头竖直片刻", "宝宝呈仰卧姿势，轻轻握住宝宝双肩(四指并拢至于肩胛骨外侧，食指不能触碰颈部，将宝宝慢慢拉坐起来，宝宝头部可以2秒(含)以上。")
                })),

                new CheckSheetDimension("精细动作", Arrays.asList(new CheckSheetTarget[]{
                        new CheckSheetTarget("△","2俯卧头部翘动", "宝宝呈俯卧姿势时，能尝试抬头。"),
                        new CheckSheetTarget("△111","2抬肩坐起头竖直片刻", "宝宝呈仰卧姿势，轻轻握住宝宝双肩(四指并拢至于肩胛骨外侧，食指不能触碰颈部，将宝宝慢慢拉坐起来，宝宝头部可以2秒(含)以上。")
                })),

                new CheckSheetDimension("反应能力", Arrays.asList(new CheckSheetTarget[]{
                        new CheckSheetTarget("△","3俯卧头部翘动", "宝宝呈俯卧姿势时，能尝试抬头。"),
                        new CheckSheetTarget("△","3抬肩坐起头竖直片刻", "宝宝呈仰卧姿势，轻轻握住宝宝双肩(四指并拢至于肩胛骨外侧，食指不能触碰颈部，将宝宝慢慢拉坐起来，宝宝头部可以2秒(含)以上。")
                })),
        }));

        //响应一个创建好的本地 word 文档地址
        String file = checkSheetExportService.exportEvaluateReport(sheet);

        return StatusResponse.success(file);
    }

}
